<?php
include("../config.php");
include("../include/db_connect.php");
include("../include/session.php");
include("../include/common.php");
include("../include/search.php");

if(isset($_SESSION['user_id'])) {
	$userInfo = getUserInfo($_SESSION['user_id']);
	
	if(isset($_REQUEST['query'])) {
		$query = $_REQUEST['query'];
		$itemList = searchItem($query);
		get_page_advanced("display", "search", array("name" => $userInfo[0], "query" => $query, "items" => $itemList));
	} else {
		get_page_advanced("search", "search", array("name" => $userInfo[0]));
	}

} else {
	get_page("message", array($redirct => "../index.php"));
}
?>
